<!--
 * @Descripttion: svg组件
 * @version: 
 * @Author: lhl
 * @Date: 2024-01-09 11:38:13
 * @LastEditors: lhl
 * @LastEditTime: 2024-01-10 09:24:20
-->
<template>
  <svg aria-hidden="true" class="svg-icon" :width="width" :height="height">
    <use :xlink:href="symbolId" :fill="props.color" />
  </svg>
</template>

<script lang="ts" setup name="SvgIcon">
import { computed } from 'vue'
const props = defineProps({
  prefix: {
    type: String,
    default: 'icon'
  },
  name: {
    type: String,
    required: true
  },
  size: {
    type: String,
    default: '1em'
  },
  width: {
    type: String
  },
  height: {
    type: String
  },
  color: {
    type: String,
    default: 'currentColor'
  }
})
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const width = computed(() => (props.width ? props.width : props.size))
const height = computed(() => (props.height ? props.height : props.size))
</script>

<style lang="scss" scoped>
.svg-icon {
  fill: currentColor;
  outline: none;
  font-size: 14px;
  width: 26px;
  height: 26px;
}
</style>
